//
//  userInfoTool.m
//  YidianCan_Business
//
//  Created by sheldon on 14/12/11.
//  Copyright (c) 2014年 John. All rights reserved.
//

#import "userInfoTool.h"
@interface userInfoTool()


@end
static dispatch_once_t once;
@implementation userInfoTool


//}
- (id)init{
    
    if (self = [super init]) {
        
        NSDictionary * dic = [[NSUserDefaults standardUserDefaults] objectForKey:userInf];
        self.address = dic[@"address"];
        self.head = dic[@"head"];
        self.ID = dic[@"id"];
        self.login_time = dic[@"login_time"];
        self.money = dic[@"money"];
        self.nick_name = dic[@"nick_name"];
        self.phone = dic[@"phone"];
        self.phone_bind = dic[@"phone_bind"];
        self.register_time = dic[@"register_time"];
        self.user_name = dic[@"user_name"];
        self.user_type = dic[@"user_type"];
        self.token = dic[@"token"];

    }
    return self;
}
+ (userInfoTool *)share{

    static userInfoTool * userInfo = nil;
    dispatch_once(&once, ^{
       
        userInfo = [[userInfoTool alloc] init];
    });
    return userInfo;
}
+(void)updateInfo:(NSDictionary *)param1{

    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:param1];
    for (NSString *key in param.allKeys) {
        
        if ([param[key] isKindOfClass:[NSNull class]]) {
            
            param[key] = @"";
        }
    }
    [[NSUserDefaults standardUserDefaults] setObject:param forKey:userInf];
    [[NSUserDefaults standardUserDefaults] synchronize];
    once = 0;
    
}
+ (void)removeUserInfo{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:userInf];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
//- (void)hasLogIn:(NSNotification *)no{
//
//    once = 0;
//}
+ (id)initVcWithStoryBoardName:(NSString *)storyBoardName andStoryBoardID:(NSString *)StoryID{
    UIStoryboard * story = [UIStoryboard storyboardWithName:storyBoardName bundle:nil];
    id Vc = [story instantiateViewControllerWithIdentifier:StoryID];
    return Vc;
    
}
@end
